001    /**
002     * Created by IntelliJ IDEA.
003     * User: Wei Wang
004     * Date: Feb 27, 2003
005     * Time: 1:27:26 PM
006     */
007    
008    package EVolve.util.painters.shapes;
009    
010    import java.awt.*;
011    
012    public class Line extends Shape implements Cloneable{
013        private int lastX, lastY, size;
014    
015        public Line(long entity_type, long entity_id, int size) {
016            super(entity_type, entity_id);
017            lastX = lastY = -1;
018            this.size = size;
019        }
020    
021        public void draw(Graphics2D g) {
022            if (color != null) g.setColor(color);
023    
024            if (lastX == -1)
025                g.drawLine(x,y,x,y);
026            else
027                g.drawLine(lastX,lastY,x,y);
028            lastX = x;
029            lastY = y;
030        }
031    
032        public void fill(Graphics2D g) {
033        }
034    
035        public String getName() {
036            return "Line";
037        }
038    
039        public boolean insideShape(int x, int y) {
040            return false;
041        }
042    
043        public int getWidth() {
044            return size;
045        }
046    
047        public int getHeight() {
048            return size;
049        }
050    
051        public void setSize(int width, int height) {
052            size = width;
053        }
054    
055        public Object clone() {
056            Line o = (Line)super.clone();
057    
058            o.lastX = -1;
059            o.lastY = -1;
060            return o;
061        }
062    }